package net.sk.china.front.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.sk.china.common.response.CommonResult;
import net.sk.china.front.response.product.ProductDetailResponse;
import net.sk.china.front.service.product.StoreProductService;
import org.springframework.web.bind.annotation.*;

/**
 * +----------------------------------------------------------------------
 * | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2018-2024 聊来All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">apache</a> )
 * +----------------------------------------------------------------------
 * | @Author: 聊来 <18970881148@qq.com>
 * +----------------------------------------------------------------------
 * | DateTime: 2024/6/12 16:09
 * +----------------------------------------------------------------------
 */

@RestController
@RequestMapping("product/")
@Api(tags = "商品")
public class ProductController {

    private final StoreProductService storeProductService;

    public ProductController(StoreProductService storeProductService) {
        this.storeProductService = storeProductService;
    }

    @ApiOperation(value = "商品详情")
    @RequestMapping(value = "detail/{id}", method = RequestMethod.GET)
    @ApiImplicitParam(name = "type", value = "normal-正常，video-视频", dataTypeClass = String.class)
    public CommonResult<ProductDetailResponse> getDetail(@PathVariable(value = "id") Integer id, @RequestParam(value = "type", defaultValue = "normal") String type) {
        return CommonResult.success(storeProductService.getDetail(id, type));
    }
}
